import Router from '@koa/router';
import AuthController from '@/controllers/AuthController';
import { auth } from '@/middlewares';

const router = new Router({
  prefix: '/api/auth',
});

/**
 * 认证路由
 */

// 登录
router.post('/login', AuthController.login.bind(AuthController));

// 获取可用租户列表（公开接口）
router.get('/tenants', AuthController.getAvailableTenants.bind(AuthController));

// 登出
router.post('/logout', auth, AuthController.logout.bind(AuthController));

// 刷新 Token
router.post('/refresh', auth, AuthController.refreshToken.bind(AuthController));

// 修改密码
router.post('/change-password', auth, AuthController.changePassword.bind(AuthController));

// 获取当前用户信息
router.get('/me', auth, AuthController.getCurrentUser.bind(AuthController));

// 获取当前用户权限列表
router.get('/permissions', auth, AuthController.getCurrentUserPermissions.bind(AuthController));

// 更新当前用户信息
router.put('/me', auth, AuthController.updateCurrentUser.bind(AuthController));

export default router;

